/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qdu.servlet;

import com.qdu.entity.Movie;
import com.qdu.service.MovieService;
import com.qdu.service.impl.MovieServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Lenovo
 */
@WebServlet("/mms")
public class ModifyMovieServlet extends HttpServlet{
    MovieService movieService = new MovieServiceImpl();
    
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        //1. 获取请求参数
        
        req.setCharacterEncoding("utf-8");
        String movieId = req.getParameter("movieId");
        String mchineseName = req.getParameter("mchineseName");
        String moriginalName = req.getParameter("moriginalName");
        String mtype = req.getParameter("mtype");
        String mreleaseDate = req.getParameter("mreleaseDate");
        String mlanguage = req.getParameter("mlanguage");
        String mcountry = req.getParameter("mcountry");
        String mdirector = req.getParameter("mdirector");

        
        Movie movie = new Movie(movieId,mchineseName, moriginalName,mtype,mreleaseDate,mlanguage,mcountry,mdirector);

        //2. 调用业务逻辑，完成请求处理
        
        int rows=movieService.modifyMovieInfo(movie);
        
        //3. 生成响应内容，这里返回受影响的行数用于判断是否修改成功
        resp.getWriter().print(rows);
    
}
}